package com.example.sls.controller.logistics;

import com.example.sls.pojo.logistics.EquipmentMaintenance;
import com.example.sls.service.intserfaces.logistics.EquipmentMaintenanceService;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * 设备维护记录表(EquipmentMaintenance)表控制层
 *
 * @author 蓝江富
 * @since 2024-06-19 13:23:43
 */
@RestController
@RequestMapping("logistics/equipmentMaintenance")
public class EquipmentMaintenanceController {
  @Autowired
  EquipmentMaintenanceService equipmentMaintenanceService;

  @InitBinder
  public void initDateFormate(WebDataBinder dataBinder) {
    dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
  }
  @GetMapping("queryById")
  EquipmentMaintenance queryById(Integer id) {
    return equipmentMaintenanceService.queryById(id);
  }

  @GetMapping("queryAll")
  List<EquipmentMaintenance> queryAll() {
    return equipmentMaintenanceService.queryAllByLimit(new EquipmentMaintenance(), 999999, 0);
  }
  @GetMapping("queryAllByLimit")
  List<EquipmentMaintenance> queryAllByLimit(EquipmentMaintenance equipmentMaintenance, Integer pageSize, Integer offset) {
    return equipmentMaintenanceService.queryAllByLimit(equipmentMaintenance, pageSize, offset);
  }

  @GetMapping("count")
  long count() {
    return equipmentMaintenanceService.count();
  }

  @GetMapping("insert")
  int insert(EquipmentMaintenance equipmentMaintenance) {
    return equipmentMaintenanceService.insert(equipmentMaintenance);
  }

  @GetMapping("update")
  int update(EquipmentMaintenance equipmentMaintenance) {
    return equipmentMaintenanceService.update(equipmentMaintenance);
  }

  @GetMapping("deleteById")
  int deleteById(Integer id) {
    return equipmentMaintenanceService.deleteById(id);
  }
}

